namespace QMVnSoft.Lists
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormDmNhTsEditor : FormListEditor
    {
        private IContainer components;
        private LabelControl lblMa_Nh_Ts;
        private LabelControl lblNh_Cuoi_Ts;
        private LabelControl lblNh_Cuoi_Ts0;
        private LabelControl lblNh_Me_Ts;
        private LabelControl lblTen_Nh_Ts;
        private LabelControl lblTen_Nh_TsE;
        private TextControl txtMa_Nh_Ts;
        private TextOption txtNh_Cuoi_Ts;
        private TextSearch txtNh_Me_Ts;
        private TextControl txtTen_Nh_Me;
        private TextControl txtTen_Nh_Ts;
        private TextControl txtTen_Nh_TsE;

        public FormDmNhTsEditor()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormDmNhTsEditor));
            this.txtMa_Nh_Ts = new QMVnSoft.Controls.TextControl();
            this.lblMa_Nh_Ts = new QMVnSoft.Controls.LabelControl();
            this.txtTen_Nh_Ts = new QMVnSoft.Controls.TextControl();
            this.lblTen_Nh_Ts = new QMVnSoft.Controls.LabelControl();
            this.txtTen_Nh_TsE = new QMVnSoft.Controls.TextControl();
            this.lblTen_Nh_TsE = new QMVnSoft.Controls.LabelControl();
            this.lblNh_Cuoi_Ts = new QMVnSoft.Controls.LabelControl();
            this.txtNh_Cuoi_Ts = new QMVnSoft.Controls.TextOption();
            this.txtNh_Me_Ts = new QMVnSoft.Controls.TextSearch();
            this.txtTen_Nh_Me = new QMVnSoft.Controls.TextControl();
            this.lblNh_Me_Ts = new QMVnSoft.Controls.LabelControl();
            this.lblNh_Cuoi_Ts0 = new QMVnSoft.Controls.LabelControl();
            this.SuspendLayout();
            // 
            // lblPhan_Loai
            // 
            this.lblPhan_Loai.Location = new System.Drawing.Point(12, 141);
            // 
            // txtMa_Loai1
            // 
            this.txtMa_Loai1.FirstFilter = "Type = \'NF1\'";
            this.txtMa_Loai1.Location = new System.Drawing.Point(123, 138);
            this.txtMa_Loai1.TabIndex = 6;
            // 
            // txtMa_Loai2
            // 
            this.txtMa_Loai2.FirstFilter = "Type = \'NF2\'";
            this.txtMa_Loai2.Location = new System.Drawing.Point(251, 138);
            this.txtMa_Loai2.TabIndex = 7;
            // 
            // txtMa_Loai3
            // 
            this.txtMa_Loai3.FirstFilter = "Type = \'NF3\'";
            this.txtMa_Loai3.Location = new System.Drawing.Point(379, 138);
            this.txtMa_Loai3.TabIndex = 8;
            // 
            // txtMa_Nh_Ts
            // 
            this.txtMa_Nh_Ts.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Nh_Ts.CheckTextSearched = false;
            this.txtMa_Nh_Ts.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Nh_Ts.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Nh_Ts.Location = new System.Drawing.Point(123, 28);
            this.txtMa_Nh_Ts.MaxLength = 32;
            this.txtMa_Nh_Ts.Name = "txtMa_Nh_Ts";
            this.txtMa_Nh_Ts.OldValue = null;
            this.txtMa_Nh_Ts.Size = new System.Drawing.Size(126, 20);
            this.txtMa_Nh_Ts.TabIndex = 1;
            this.txtMa_Nh_Ts.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Nh_Ts.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Nh_Ts.Value = ((object)(resources.GetObject("txtMa_Nh_Ts.Value")));
            // 
            // lblMa_Nh_Ts
            // 
            this.lblMa_Nh_Ts.AutoSize = true;
            this.lblMa_Nh_Ts.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Nh_Ts.Location = new System.Drawing.Point(12, 31);
            this.lblMa_Nh_Ts.Name = "lblMa_Nh_Ts";
            this.lblMa_Nh_Ts.Size = new System.Drawing.Size(50, 14);
            this.lblMa_Nh_Ts.TabIndex = 4;
            this.lblMa_Nh_Ts.Text = "Mã nhóm";
            // 
            // txtTen_Nh_Ts
            // 
            this.txtTen_Nh_Ts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Nh_Ts.CheckTextSearched = false;
            this.txtTen_Nh_Ts.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtTen_Nh_Ts.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Nh_Ts.Location = new System.Drawing.Point(123, 50);
            this.txtTen_Nh_Ts.MaxLength = 128;
            this.txtTen_Nh_Ts.Name = "txtTen_Nh_Ts";
            this.txtTen_Nh_Ts.OldValue = null;
            this.txtTen_Nh_Ts.Size = new System.Drawing.Size(382, 20);
            this.txtTen_Nh_Ts.TabIndex = 2;
            this.txtTen_Nh_Ts.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtTen_Nh_Ts.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtTen_Nh_Ts.Value = ((object)(resources.GetObject("txtTen_Nh_Ts.Value")));
            // 
            // lblTen_Nh_Ts
            // 
            this.lblTen_Nh_Ts.AutoSize = true;
            this.lblTen_Nh_Ts.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTen_Nh_Ts.Location = new System.Drawing.Point(12, 53);
            this.lblTen_Nh_Ts.Name = "lblTen_Nh_Ts";
            this.lblTen_Nh_Ts.Size = new System.Drawing.Size(54, 14);
            this.lblTen_Nh_Ts.TabIndex = 4;
            this.lblTen_Nh_Ts.Text = "Tên nhóm";
            // 
            // txtTen_Nh_TsE
            // 
            this.txtTen_Nh_TsE.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Nh_TsE.CheckTextSearched = false;
            this.txtTen_Nh_TsE.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtTen_Nh_TsE.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Nh_TsE.Location = new System.Drawing.Point(123, 72);
            this.txtTen_Nh_TsE.MaxLength = 128;
            this.txtTen_Nh_TsE.Name = "txtTen_Nh_TsE";
            this.txtTen_Nh_TsE.OldValue = null;
            this.txtTen_Nh_TsE.Size = new System.Drawing.Size(382, 20);
            this.txtTen_Nh_TsE.TabIndex = 3;
            this.txtTen_Nh_TsE.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtTen_Nh_TsE.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtTen_Nh_TsE.Value = ((object)(resources.GetObject("txtTen_Nh_TsE.Value")));
            // 
            // lblTen_Nh_TsE
            // 
            this.lblTen_Nh_TsE.AutoSize = true;
            this.lblTen_Nh_TsE.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTen_Nh_TsE.Location = new System.Drawing.Point(12, 75);
            this.lblTen_Nh_TsE.Name = "lblTen_Nh_TsE";
            this.lblTen_Nh_TsE.Size = new System.Drawing.Size(73, 14);
            this.lblTen_Nh_TsE.TabIndex = 4;
            this.lblTen_Nh_TsE.Text = "Tên tiếng Anh";
            // 
            // lblNh_Cuoi_Ts
            // 
            this.lblNh_Cuoi_Ts.AutoSize = true;
            this.lblNh_Cuoi_Ts.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNh_Cuoi_Ts.Location = new System.Drawing.Point(12, 97);
            this.lblNh_Cuoi_Ts.Name = "lblNh_Cuoi_Ts";
            this.lblNh_Cuoi_Ts.Size = new System.Drawing.Size(57, 14);
            this.lblNh_Cuoi_Ts.TabIndex = 4;
            this.lblNh_Cuoi_Ts.Text = "Nhóm cuối";
            // 
            // txtNh_Cuoi_Ts
            // 
            this.txtNh_Cuoi_Ts.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtNh_Cuoi_Ts.CheckTextSearched = false;
            this.txtNh_Cuoi_Ts.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtNh_Cuoi_Ts.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNh_Cuoi_Ts.InputMask = "C,K";
            this.txtNh_Cuoi_Ts.Location = new System.Drawing.Point(123, 94);
            this.txtNh_Cuoi_Ts.Name = "txtNh_Cuoi_Ts";
            this.txtNh_Cuoi_Ts.OldValue = null;
            this.txtNh_Cuoi_Ts.Size = new System.Drawing.Size(23, 20);
            this.txtNh_Cuoi_Ts.TabIndex = 4;
            this.txtNh_Cuoi_Ts.Text = "C";
            this.txtNh_Cuoi_Ts.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtNh_Cuoi_Ts.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtNh_Cuoi_Ts.Value = "C";
            // 
            // txtNh_Me_Ts
            // 
            this.txtNh_Me_Ts.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtNh_Me_Ts.CheckTextSearched = false;
            this.txtNh_Me_Ts.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtNh_Me_Ts.EmptyIsValid = true;
            this.txtNh_Me_Ts.FieldDisplay = "Ten_Nh_Ts";
            this.txtNh_Me_Ts.FirstFilter = "Nh_Cuoi_Ts = \'K\'";
            this.txtNh_Me_Ts.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNh_Me_Ts.Location = new System.Drawing.Point(123, 116);
            this.txtNh_Me_Ts.MaxLength = 32;
            this.txtNh_Me_Ts.Name = "txtNh_Me_Ts";
            this.txtNh_Me_Ts.OldValue = null;
            this.txtNh_Me_Ts.Size = new System.Drawing.Size(126, 20);
            this.txtNh_Me_Ts.TabIndex = 5;
            this.txtNh_Me_Ts.TableName = "DMNHTS";
            this.txtNh_Me_Ts.TextDisplay = this.txtTen_Nh_Me;
            this.txtNh_Me_Ts.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtNh_Me_Ts.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtNh_Me_Ts.Value = ((object)(resources.GetObject("txtNh_Me_Ts.Value")));
            // 
            // txtTen_Nh_Me
            // 
            this.txtTen_Nh_Me.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Nh_Me.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Nh_Me.CheckTextSearched = false;
            this.txtTen_Nh_Me.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nh_Me.Enabled = false;
            this.txtTen_Nh_Me.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Nh_Me.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nh_Me.Location = new System.Drawing.Point(255, 119);
            this.txtTen_Nh_Me.Name = "txtTen_Nh_Me";
            this.txtTen_Nh_Me.OldValue = null;
            this.txtTen_Nh_Me.Size = new System.Drawing.Size(250, 13);
            this.txtTen_Nh_Me.TabIndex = 13;
            this.txtTen_Nh_Me.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Nh_Me.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Nh_Me.Value = ((object)(resources.GetObject("txtTen_Nh_Me.Value")));
            // 
            // lblNh_Me_Ts
            // 
            this.lblNh_Me_Ts.AutoSize = true;
            this.lblNh_Me_Ts.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNh_Me_Ts.Location = new System.Drawing.Point(12, 119);
            this.lblNh_Me_Ts.Name = "lblNh_Me_Ts";
            this.lblNh_Me_Ts.Size = new System.Drawing.Size(51, 14);
            this.lblNh_Me_Ts.TabIndex = 4;
            this.lblNh_Me_Ts.Text = "Nhóm mẹ";
            // 
            // lblNh_Cuoi_Ts0
            // 
            this.lblNh_Cuoi_Ts0.AutoSize = true;
            this.lblNh_Cuoi_Ts0.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNh_Cuoi_Ts0.ForeColor = System.Drawing.Color.Blue;
            this.lblNh_Cuoi_Ts0.Location = new System.Drawing.Point(152, 97);
            this.lblNh_Cuoi_Ts0.Name = "lblNh_Cuoi_Ts0";
            this.lblNh_Cuoi_Ts0.Size = new System.Drawing.Size(202, 14);
            this.lblNh_Cuoi_Ts0.TabIndex = 33;
            this.lblNh_Cuoi_Ts0.Text = "C-Nhóm cuối, K-Không phải là nhóm cuối";
            // 
            // FormDmNhTsEditor
            // 
            this.AddTitleText = "Thêm mới nhóm tài sản, công cụ";
            this.ClientSize = new System.Drawing.Size(522, 172);
            this.Controls.Add(this.lblNh_Cuoi_Ts0);
            this.Controls.Add(this.txtTen_Nh_Me);
            this.Controls.Add(this.txtNh_Me_Ts);
            this.Controls.Add(this.txtNh_Cuoi_Ts);
            this.Controls.Add(this.lblTen_Nh_TsE);
            this.Controls.Add(this.lblNh_Cuoi_Ts);
            this.Controls.Add(this.lblTen_Nh_Ts);
            this.Controls.Add(this.lblNh_Me_Ts);
            this.Controls.Add(this.lblMa_Nh_Ts);
            this.Controls.Add(this.txtTen_Nh_TsE);
            this.Controls.Add(this.txtTen_Nh_Ts);
            this.Controls.Add(this.txtMa_Nh_Ts);
            this.EditTitleText = "Sửa nhóm tài sản, công cụ";
            this.FirstFreeCode = "NF1";
            this.Name = "FormDmNhTsEditor";
            this.SecondFreeCode = "NF2";
            this.Text = "Thêm mới nhóm tài sản, công cụ";
            this.ThirdFreeCode = "NF3";
            this.Controls.SetChildIndex(this.lblPhan_Loai, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai1, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai2, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai3, 0);
            this.Controls.SetChildIndex(this.txtMa_Nh_Ts, 0);
            this.Controls.SetChildIndex(this.txtTen_Nh_Ts, 0);
            this.Controls.SetChildIndex(this.txtTen_Nh_TsE, 0);
            this.Controls.SetChildIndex(this.lblMa_Nh_Ts, 0);
            this.Controls.SetChildIndex(this.lblNh_Me_Ts, 0);
            this.Controls.SetChildIndex(this.lblTen_Nh_Ts, 0);
            this.Controls.SetChildIndex(this.lblNh_Cuoi_Ts, 0);
            this.Controls.SetChildIndex(this.lblTen_Nh_TsE, 0);
            this.Controls.SetChildIndex(this.txtNh_Cuoi_Ts, 0);
            this.Controls.SetChildIndex(this.txtNh_Me_Ts, 0);
            this.Controls.SetChildIndex(this.txtTen_Nh_Me, 0);
            this.Controls.SetChildIndex(this.lblNh_Cuoi_Ts0, 0);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        protected override void OnReset()
        {
            this.txtNh_Cuoi_Ts.ReadOnly = !base.NewChecked;
            base.OnReset();
        }

        public override bool OnSave()
        {
            DataRow localCurrentRow;
            if (string.IsNullOrEmpty(this.txtMa_Nh_Ts.Text))
            {
                MessageBox.Show("Chưa nhập mã nhóm đối tượng!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (string.IsNullOrEmpty(this.txtTen_Nh_Ts.Text))
            {
                MessageBox.Show("Chưa nhập tên nhóm đối tượng!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.NewChecked)
            {
                localCurrentRow = base.LocalTable.NewRow();
            }
            else
            {
                localCurrentRow = base.LocalCurrentRow;
            }
            localCurrentRow["Ma_Nh_Ts"] = this.txtMa_Nh_Ts.Value;
            localCurrentRow["Ten_Nh_Ts"] = this.txtTen_Nh_Ts.Value;
            localCurrentRow["Ten_Nh_TsE"] = this.txtTen_Nh_TsE.Value;
            localCurrentRow["Nh_Cuoi_Ts"] = this.txtNh_Cuoi_Ts.Value;
            localCurrentRow["Nh_Me_Ts"] = this.txtNh_Me_Ts.Value;
            localCurrentRow["Ten_Nh_Me"] = this.txtTen_Nh_Me.Value;
            localCurrentRow["Ma_Loai1"] = base.txtMa_Loai1.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            DmNhTsDataAccess access = new DmNhTsDataAccess();
            if (base.ShowMessage(localCurrentRow, access.SaveRow(base.NewChecked, localCurrentRow)))
            {
                return false;
            }
            if (base.NewChecked)
            {
                base.LocalTable.Rows.Add(localCurrentRow);
            }
            base.LocalCurrentRow = localCurrentRow;
            base.LocalTable.AcceptChanges();
            this.txtMa_Nh_Ts.Focus();
            return base.OnSave();
        }

        public override void OnShow()
        {
            this.txtMa_Nh_Ts.Value = base.LocalCurrentRow["Ma_Nh_Ts"];
            this.txtTen_Nh_Ts.Value = base.LocalCurrentRow["Ten_Nh_Ts"];
            this.txtTen_Nh_TsE.Value = base.LocalCurrentRow["Ten_Nh_TsE"];
            this.txtNh_Cuoi_Ts.Value = base.LocalCurrentRow["Nh_Cuoi_Ts"];
            this.txtNh_Me_Ts.Value = base.LocalCurrentRow["Nh_Me_Ts"];
            this.txtTen_Nh_Me.Value = base.LocalCurrentRow["Ten_Nh_Me"];
            base.txtMa_Loai1.Value = base.LocalCurrentRow["Ma_Loai1"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];
            base.OnShow();
        }
    }
}

